package com.icarsaas.saas.tenant.cars.customer.model;

import com.icarsaas.saas.common.enums.StatusEnum;
import com.icarsaas.saas.component.base.DataEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.*;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Date;

/**
 * 会籍表
 */
@Data @Entity @Table(name = "cars_member")
@DynamicInsert @DynamicUpdate
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@EntityListeners(AuditingEntityListener.class)
//@org.hibernate.annotations.Table(appliesTo = "cars_member",comment="会籍表")
@ApiModel(description = "会籍信息")
public class Member extends DataEntity {
    @Id
    @GeneratedValue(generator="system-uuid")
    @GenericGenerator(name="system-uuid", strategy = "org.hibernate.id.UUIDGenerator")
    @Column(name = "id", nullable = false, insertable = true, updatable = true, length = 36)
    private String id;
//    @Column(columnDefinition="varchar(36) COMMENT '开卡门店'")
    @Column(length = 36) @ApiModelProperty(value = "开卡门店")
    private String storeId;//开卡门店
    @Column(length = 36) @ApiModelProperty(value = "所属客户")
    private String customerId;//所属客户

    @Column(columnDefinition="varchar(30) COMMENT '会员类型'")
    private String type;//会员类型：月卡、年卡、贵宾会、豪华会.....
    @Column(columnDefinition="varchar(30) COMMENT '会籍编号'")
    private String no;//编号
    @Column(columnDefinition="varchar(50) COMMENT '会员名称'")
    private String name;//会员名称
    @Column(columnDefinition="varchar(50) COMMENT '手机号码'")
    private String mobile;//手机号码

    @Column(columnDefinition="decimal(10,0) COMMENT '初始点值'")
    private BigDecimal point;//初始点值、次数
    @Column(columnDefinition="decimal(10,2) COMMENT '初始金额'")
    private BigDecimal money;//初始金额
    @Column(columnDefinition="datetime COMMENT '生效时间'") @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date effDate;//生效时间
    @Column(columnDefinition="datetime COMMENT '失效时间'") @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date expDate;//失效时间
    @Column(columnDefinition="datetime COMMENT '延期时间'") @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date delayDate;//延期时间
    @Column(length = 4) @ApiModelProperty(value = "状态")
    private Byte status = StatusEnum.OK.getCode();// 会籍状态，应该在到期后自动失效
}
